#include <iostream>

#include "hangman.h"

using namespace std;

hangman::hangman()
{
	triesLeft = 7;

	gallos = "";
	gallos += " -------|\n";
	gallos += " |      |\n";
	gallos += "        |\n";
	gallos += "        |\n";
	gallos += "        |\n";
	gallos += "        |\n";
	gallos += "      -----\n";
}
hangman::~hangman()
{

}

bool hangman::gameOver()
{
	return (!hasTriesLeft());
}

bool hangman::hasTriesLeft()
{
	return triesLeft > 0;
}

void hangman::drawBoard()
{
	triesLeft--;
	drawGallos();
}

//private
void hangman::drawGallos()
{
	/*	
	Index of body part locations gallos
		Head:		21
		Body:		31
		leftArm:	30
		rightArm:	32
		leftLeg:	40
		rightLeg:	42
	*/

	switch (triesLeft)
	{
		default:
//			message += "\nUnknown value of triesLeft.\n";
			break;
		case 6:	
			break;
		case 0:
			gallos.replace(42, 1, 1, '\\');	//right leg
			break;
		case 1:
			gallos.replace(40, 1, 1, '/');	//left leg
			break;
		case 2:
			gallos.replace(32, 1, 1, '-');	//right arm
			break;
		case 3:
			gallos.replace(30, 1, 1, '-');	//left arm
			break;
		case 4:
			gallos.replace(31, 1, 1, '|');	//body
			break;
		case 5:
			gallos.replace(21, 1, 1, '0');	//head
			break;
	}
	
	cout << gallos;
}